import ora from 'ora'
import chalk from 'chalk'
import { build } from 'vite'

async function buildApp() {
    const spinner = ora({
        text: chalk.blue('Building for production...\n'),
        color: 'blue',
        spinner: 'dots'
    }).start()

    try {
        await build()
        spinner.succeed(chalk.green('Build complete! 🎉'))
        console.log(chalk.cyan('\nFile in ') + chalk.yellow('dist') + chalk.cyan(' folder are ready to be deployed!\n'))
    } catch (error) {
        spinner.fail(chalk.red('Build failed! 😢'))
        console.error(error)
        process.exit(1)
    }
}

buildApp() 